package com.shadow.demo.data;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shadow.demo.common.bo.R;
import org.springframework.stereotype.Component;

@Component
public class BaseController {

    public static final int LayUi_FAIL     = 1;     // 正常
    public static final int LayUi_SUCCESS  = 0;     // 失败

    public R successPage(final Page<?> page) {
        R r = new R();
        r.put(R.CODE, LayUi_SUCCESS); // LayUi 中0成功, 1失败
        r.put(R.STATUS, R.STATUS_SUCCESS);
        r.put(R.DATA, page.getRecords());
        r.put(R.COUNT, page.getTotal());
        r.put(R.MSG, R.MSG_SUCCESS);
        return r;
    }
}
